/-app ...
/-app/tests ...
TestCase.ts
TestPage.ts
Application.ts
/-boot
/-imports
/-storage
/-tests
_sampleTests.ts
/-typings
stringUtils.ts
teapo.html
34
    private _startSync() {
35
 
36
      this.state(TestCase.State.Running);
37
      this.runtime(0);
38
      this._started = Date.now();
39
 
40
      var failure: Error;
41
      var failed = false;
42
      try {
43
        this._test();
44
      }
45
      catch (error) {
46
        failed = true;
47
        failure = error;
48
      }
49
 
50
      this.runtime(Date.now() - this._started);
51
 
52
      if (failed) {
53
        this.failure(failure);
54
        this.state(TestCase.State.Failed);
55
      }
56
      else {
57
        this.state(TestCase.State.Succeeded);
58
      }
59
    }
60
 
61
    private _startAsync(callback?: () => void) {
62
      this.state(TestCase.State.Running);
63
      this.runtime(0);
64
      this._started = Date.now();
65
 
66
                        
67
      var failure: Error;
68
      var failedSynchrously = false;
69
      try {
70
        this._test((failure?) => { 
71
 
72
          this.runtime(Date.now() - this._started);
73
 
74
          if (failure) {
75
            this.failure(failure);
76
            this.state(TestCase.State.Failed);
77
          }
78
          else {
79
            this.state(TestCase.State.Succeeded);
80
          }
81
 
82
          if (callback)
83
            callback();
84
        });
85
      }
86
      catch (error) {
87
        failedSynchrously = true;
88
        failure = error;
89
      }
90
 
91
      this.runtime(Date.now() - this._started);
92
 
93
      if (failedSynchrously) {
94
        this.failure(failure);
95
        this.state(TestCase.State.Failed);
96
 
97
        if (callback)
98
          callback();
99
      }
100
    }
101
  }
102
 
103
  export module TestCase {
104
 
105
    export enum State {
106
      NotStarted,
107
      Running,
108
      Succeeded,
109
      Failed
110
    }
111
 
112
  }
113
 
114
}